package com.jmcba.daily.damaged;

import java.io.Serializable;

public abstract class Component implements Serializable {
    /**
     * 寿命
     * 行驶距离
     */
    // 千公里
    int lifetimeDistance;
    int lifetimeAge = 65535; // TODO
    int lifetimeAgeMo;
    int priceUnit = 6;

    Usage usage;

    int age;
    int ageMo;

    int replaced() {
        if (true) { // TODO
            return (int) Math.ceil((float) this.ageMo / this.lifetimeAgeMo);
        } else { // TODO
            throw new RuntimeException("行不通" + this.lifetimeAgeMo);
        }
    }

    public int calcCost() {
        return this.priceUnit * this.replaced();
    }


    public Component(Usage usage) {
        this.usage = usage;
        this.age = this.usage.age;

        // TODO
        this.ageMo = this.age * 12;
    }

    /** TODO */
    public int fetchVal() {
        return this.lifetimeAgeMo;
    }
}
